package com.yang.guliproduct.web;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yang.guliproduct.entity.PmsCategory;
import com.yang.guliproduct.service.impl.PmsCategoryServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.List;

@Controller
public class IndexController {

    @Autowired
    private PmsCategoryServiceImpl pmsCategoryService;

    @GetMapping({"/","index.html"})
    public String indexPage(Model model){
        QueryWrapper<PmsCategory> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("cat_level",1);
        List<PmsCategory> pmsCategories = pmsCategoryService.list(queryWrapper);
        model.addAttribute("Categories",pmsCategories);
        return "index";
    }
}
